﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Hospitals/Master/HospitalsMaster.Master"
    AutoEventWireup="true" CodeBehind="SelectInvoice.aspx.cs" Inherits="HZ.DrugTrade.Web.Hospitals.Collection.SelectInvoice" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <script type="text/javascript" language="javascript">
        function addInfo() {
            if (checkSelectedItems('ctl00_ContentPlaceHolder1_gvwDataInfo', '请至少选定一条记录！')) {
                var obj = new Object;
                obj.Receiptid = "";
                obj.Allmoney = "";
                obj.SID = "";
                var i, money = 0;
                var a = document.getElementsByName('chkChose');
                for (i = 0; i < a.length; i++) {
                    if (a[i].checked == true) {
                        obj.Receiptid += a[i].value + ",";
                        money += Number(a[i].getAttribute('money'));
                        obj.SID += "'" + a[i].getAttribute('sid') + "',";
                    }
                }
                if (window.confirm("您所选择的发票总金额为" + money.toFixed(2) + ",\n\n是否保存?") == true) {
                    obj.Allmoney = money;
                    document.getElementById("<%=hfdIds.ClientID %>").value = obj.Receiptid;
                    document.getElementById("<%=hfdSIds.ClientID %>").value = obj.SID;
                    document.getElementById("<%=allMoney.ClientID %>").value = obj.Allmoney;
                    return true;
                }
                else {
                    return false;
                }
            }
            else {
                return false;
            }
        }
    
         
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="maincon">
        <div class="note">
            选择发票</div>
        <div class="note2">
        </div>
        <table width="100%">
            <tr>
                <td>
                    <asp:Label ID="Label1" runat="server" Text="起始时间："></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtStartDate" runat="server" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
                        MaxLength="10"></asp:TextBox>
                </td>
                <td>
                    <asp:Label ID="Label2" runat="server" Text="截至时间："></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtEndDate" runat="server" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
                            MaxLength="10"></asp:TextBox>
                </td>
                <td>
                    <hz:HzButton ID="btnQuery" runat="server" Text="查询" OnClick="btnQuery_Click" CssClass="btn"
                        Width="40px" />
                </td>
            </tr>
        </table>
    </div>
    <br />
    <asp:GridView ID="gvwDataInfo" runat="server" AutoGenerateColumns="False" CssClass="mainlist"
        EmptyDataText="暂无符合条件的数据！">
        <Columns>
            <asp:TemplateField HeaderText="序号">
                <ItemTemplate>
                    <%#Container.DataItemIndex + 1 + AspNetPager1.PageSize*(AspNetPager1.CurrentPageIndex-1)%></ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="发票号">
                <ItemTemplate>
                    <%# Eval ("InvoiceID")%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="InvoiceSerialID" HeaderText="发票流水号" Visible="false" />
            <asp:BoundField DataField="InvoiceTime" HeaderText="发票时间" DataFormatString="{0:d}" />
            <asp:BoundField DataField="TotalAmount" HeaderText="发票金额" />
            <asp:TemplateField HeaderText=" ">
                <HeaderTemplate>
                    <input id="chkAll" name="chkAll" type="checkbox" onclick="SelectAllCheckboxes(this,'ctl00_ContentPlaceHolder1_gvwDataInfo','chkAll'); " />
                </HeaderTemplate>
                <ItemTemplate>
                    <input type="checkbox" name="chkChose" id="chkChose" value='<%#Eval("InvoiceID")%>'
                        money='<%#Eval("TotalAmount")%>' sid='<%#Eval("InvoiceSerialID")%>' onclick="chkChecked(this,'ctl00_ContentPlaceHolder1_gvwDataInfo','chkAll');" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <div class="page">
        <webdiyer:AspNetPager ID="AspNetPager1" runat="server" OnPageChanged="AspNetPager1_OnPageChanged">
        </webdiyer:AspNetPager>
    </div>
    <div class="listip">
        <ul>
            <li>提示：<span>请选择需要结算的发票。</span></li></ul>
    </div>
    <div class="listctrl">
        <asp:Button runat="server" ID="btnSelect" OnClientClick="if(addInfo()){}else{ return false;}"
            CssClass="btn" Text="选择" OnClick="btnSelect_Click" />
        &nbsp;<asp:HiddenField runat="server" ID="hfdIds" />
        <asp:HiddenField runat="server" ID="allMoney" />
        <asp:HiddenField runat="server" ID="hfdSIds" />
        <%--        <input id="Button1" type="button" onclick="openner=null;window.close();" value="关闭"
            class="btn" />
        <input id="Button2" type="button" onclick="addInfo();" value="选择" class="btn" />--%>
    </div>
</asp:Content>
